import { Component, OnInit } from '@angular/core';
import { Router,ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-pages',
  templateUrl: './pages.component.html',
  styleUrls: ['./pages.component.scss']
})
export class PagesComponent implements OnInit {

  constructor(
    private router: Router,
    private route: ActivatedRoute,
  ) { }

  ngOnInit() {
  }

  closePop1(){
    console.log(this.route.toString())
    this.router.navigate([{outlets: { pop1: null}}],{ relativeTo: this.route.parent});
  }

  closePop2(){
    // const componentName = /pop1:(\w*)/ig.exec(window.location.pathname);
    // this.router.navigateByUrl(`/pages/(pop1:${componentName[1] || 'home'})`);

    // 上下两种方法均可
    this.router.navigate([{outlets: { pop2: null}}],{ relativeTo: this.route.parent});
  }
}
